<?php

namespace App\Service;

use App\ENUM\ENUM_IS_SHOW;
use App\Service\Dao\ArticleDao;
use Hyperf\Di\Annotation\Inject;

class ArticleService
{
    #[inject]
    protected ArticleDao $articleDao;


    public function getColumnMessage($id){
        return $this->articleDao->articleColumnMessage($id);;
    }

    public function getArticleColumn(){
        return $this->articleDao->getArticleColumn();

    }

    public function getArticleList($title, $column_id, $page_size)
    {
        $where = [];

        var_dump($title,$column_id);
        if (!empty($title) && $title != '') {
            $where[] = ['title', 'like', "%$title%"];
        }

        if (!empty($column_id) && $column_id != '') {
            $where[] = ['column_id', '=', $column_id];
        }

        var_dump($where);

        return $this->articleDao->getArticleList($where, $page_size);

    }



    public function getArticleDetail($id)
    {
        $where = [
            ['id','=',$id]
        ];
        return $this->articleDao->getArticleDetail($where);
    }
}